﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace NinjaToolbox.SubComponentModule
{
    public class SubComponentModuleDynamicLoadExample : MonoBehaviour
    {
        public SubComponentMonoContainer subComponentMonoContainer;
        SubComponentModuleExample mInstance;


        [ContextMenu("AddComponent(Enabled)")]
        void AddComponent()
        {
            mInstance = SubComponentFactory.CreateSubComponent<SubComponentModuleExample_Model>() as SubComponentModuleExample;
            subComponentMonoContainer.AddSubComponent(mInstance);
        }

        [ContextMenu("AddComponent(Disabled)")]
        void AddComponent_Disabled()
        {
            mInstance = SubComponentFactory.CreateSubComponent<SubComponentModuleExample_Model>() as SubComponentModuleExample;
            mInstance.GetModel().Enabled = false;
            subComponentMonoContainer.AddSubComponent(mInstance);
        }

        [ContextMenu("RemoveComponent")]
        void RemoveComponent()
        {
            subComponentMonoContainer.RemoveSubComponent(mInstance);
        }
    }
}
